<template>
  <div>
    <div id="main" :style="style"/>
  </div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: "sunriseChart",
  data(){
    return{
      style:{width:'100%',height:'100%'}
    }
  },
  mounted(){
    this.sunriseChartInit()
  },
  methods:{
    sunriseChartInit(){
      const chartDom = document.getElementById('main');
      const myChart = echarts.init(chartDom);
      let option;

      const xAxisData = [];
      const data1 = [];
      const data2 = [];
      for (let i = 0; i < 100; i++) {
        xAxisData.push('A' + i);
        data1.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5);
        data2.push((Math.cos(i / 5) * (i / 5 - 10) + i / 6) * 5);
      }
      option = {
        title: {
          text: 'Bar Animation Delay'
        },
        legend: {
          data: ['bar', 'bar2']
        },
        tooltip: {},
        xAxis: {
          data: xAxisData,
          splitLine: {
            show: false
          }
        },
        yAxis: {},
        series: [
          {
            name: 'bar',
            type: 'bar',
            data: data1,
            emphasis: {
              focus: 'series'
            },
            animationDelay: function (idx) {
              return idx * 10;
            }
          },
          {
            name: 'bar2',
            type: 'bar',
            data: data2,
            emphasis: {
              focus: 'series'
            },
            animationDelay: function (idx) {
              return idx * 10 + 100;
            }
          }
        ],
        animationEasing: 'elasticOut',
        animationDelayUpdate: function (idx) {
          return idx * 5;
        }
      };

      option && myChart.setOption(option);
    }
  }
}
</script>

<style scoped>

</style>
